Dropwizards Metrics
hint: metrics.dropwizard.io v4
Main concepts here:
-
Metric: a Metric is contained in the MetricRegistry and it has an unique name (i.e. a dotted-name string) used to retrieve the Metric from the MetricRegistry.
-
MetricRegistry: it is the container for all the metrics. Usually, there is one MetricRegistry for each application.
-
Meters: a meter measures the rate of events over time (e.g., “requests per second”). A single meter includes mean rate and 1 5 15 moving averages.
- Instance:
metricRegistry.meter("the.meter.name")
- Usage:
meter.mark();
- Instance:
-
Gauges: a gauge is an instantaneous measurement of a value.
- Register with:
metricRegistry.register("the.gauge.name", theGauge);
- Register with:
-
Counters: a counter is a gauge for an
AtomicLong
. It is used to count, obviously.- Instance:
metricRegistry.counter("the.counter.name")
- Usage:
counter.inc();
and/orcounter.dec();
- Instance:
-
Histograms: a histogram measures the statistical distribution of values in a stream of data (e.g. the response times). It provides: minimum, maximum, mean, median, and percentiles (75th, 90th, 95th, 98th, 99th, and 99.9th).
- Instance:
metricRegistry.histogram("the.histogram.name")
- Usage:
histogram.update(aStreamValue);
- Instance:
-
Timers: a timer measures both the rate that a particular piece of code is called (like the a Meter) and the distribution of its duration (like a Histogram).
- Instance:
metricRegistry.time("the.timer.name")
- Usage:
context = timer.time();
andcontext.stop()
- Instance: